﻿namespace BuzzX8.Xmpp.StreamElements.Stanza
{
    public abstract class Stanza<T> : Stanza
    {
        private T type;

        protected Stanza(string name)
            : this(name, default(T))
        {
        }

        protected Stanza(string name, T type)
            : base(name)
        {
            Type = type;
        }

        public new T Type
        {
            get { return type; }
            set
            {
                Attributes["type"] = GetAttributeValueForType(value);
                type = value;
            }
        }

        protected abstract object GetAttributeValueForType(T type);
    }
}
